import request from '@/utils/request'
import { fetchDict, fetchList, fetchTree } from './common'
export function getDepartmentTree() {
  return fetchTree(null, '/api/auth/getdeptlist')
}
export function getDepartment() {
  return request({
    url: '/api/sl_department/getlist',
    method: 'post',
    data: { page_no: 1, limit: 1000, sort: 'id', where: {
      and: [{ field: 'department_type', operator: '=', value: '部门' }]
    }}
  })
}

export function getDepartmentOne(id) {
  return request({
    url: '/api/sl_department/getone',
    method: 'get',
    params: { id }
  })
}

export function getcost(dept_id = null) {
  return request({
    url: '/api/sl_department/getlist',
    method: 'post',
    data: { page_no: 1, limit: 1000, sort: 'id', where: {
      and: [
        { field: 'parent_id', operator: '=', value: dept_id },
        { field: 'department_type', operator: '=', value: '价值流' }
      ]
    }}
  })
}

export function getlines(cost_id = null) {
  return request({
    url: '/api/sl_department/getlist',
    method: 'post',
    data: { page_no: 1, limit: 1000, sort: 'id', where: {
      and: [
        { field: 'parent_id', operator: '=', value: cost_id },
        { field: 'department_type', operator: '=', value: '产线' }
      ]
    }}
  })
}
